#include <bits/stdc++.h>
#include <string>
using namespace std;

int N;

bool compare(vector<int> a, vector<int> b)
{
	if (a[0] != b[0])
		return a[0] < b[0];
	else
		return a[1] < b[1];
}

int main()
{
	cin >> N;
	int maxx = -INT_MAX;
	vector<vector<int>> v(N, vector<int>(2));
	for (int i = 0; i < N; i++)
	{
		cin >> v[i][0] >> v[i][1];
	}
	sort(v.begin(), v.end(), compare);
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			if (v[i][1] > v[j][0])
				maxx = max(maxx, v[i][1] - v[j][0] + 1);
			else
				break;
		}
	}
    cout << maxx;
	return 0;
}